﻿using System.Collections.Generic;

namespace AChance.Bll.Func
{
    public static class BllApp
    {
        public const string NAME = "Future";
        public static class Type
        {
            public const string CLI_PC = "CliPc";
            public const string CLI_PC_H5 = "CliPcH5";
            public const string CLI_PHONE = "CliPhone";
            public const string CLI_PHONE_H5 = "CliPhoneH5";
            public const string CLI_PHONE_IOS = "CliPhoneIos";
            public const string CLI_PHONE_ANDROID = "CliPhoneAndroid";
            public const string CLI_PAD = "CliPad";
            public const string CLI_PAD_H5 = "CliPadH5";
            public const string CLI_PAD_IOS = "CliPadIos";
            public const string CLI_PAD_ANDROID = "CliPadAndroid";
            public const string CLI_MP = "CliMp";
            public const string CLI_MP_WEIXIN = "CliMpWeiXin";
            public const string CLI_MP_ALIPAY = "CliMpAlipay";
            public const string CLI_MP_DING = "CliMpDing";

            public const string SER_WEB = "SerWeb";
            public const string SER_WEB_WINDOWS = "SerWebWindows";
            public const string SER_WEB_MACOS = "SerWebMacOS";
            public const string SER_WEB_LINUX = "SerWebLinux";
            public const string SER_SYS = "SerSys";
            public const string SER_SYS_WINDOWS = "SerSysWindows";
            public const string SER_SYS_MACOS = "SerSysMacOS";
            public const string SER_SYS_LINUX = "SerSysLinux";
        }
        private static Dictionary<string, string> _apps = new Dictionary<string, string>();
        static BllApp()
        {
            _apps.Add(NAME + Type.CLI_PHONE, "1.0");
        }
        /// <summary>
        /// 判断App是否存在
        /// </summary>
        public static bool Exists(string name, string type)
        {
            return Exists(name + type);
        }
        public static bool Exists(string fullName)
        {
            return _apps.ContainsKey(fullName);
        }
        //public static string GetDispName(string name)
        //{
        //    return FunMemory.Project.DispName(name, "");
        //}
        //public static string GetDispName(string name, string type)
        //{
        //    return FunMemory.Project.GetDispName(name, type);
        //}
        public static string GetVer(string name, string type)
        {
            return GetVer(name + type);
        }
        public static string GetVer(string fullName)
        {
            return _apps.ContainsKey(fullName) ? _apps[fullName] : "";
        }
        /// <summary>
        /// 校验App版本是否有效
        /// </summary>
        public static bool CheckVer(string name, string type, string ver)
        {
            return CheckVer(name + type, ver);
        }
        public static bool CheckVer(string fullName, string ver)
        {
            return _apps.ContainsKey(fullName) && ver.StartsWith(_apps[fullName]);
        }
    }
}
